//
//  ZYLTopic_listsMixedModel.m
//  Cartoon
//
//  Created by dllo on 15/7/16.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "ZYLTopic_listsMixedModel.h"
#import "AFNetworkHandler.h"
#import "ZYLSearchResultModel.h"
#import "ZYLComicModel.h"
@implementation ZYLTopic_listsMixedModel

- (void)dealloc
{
    [_action release];
    [_title release];
    [_topics release];
    [_type release];
    [super dealloc];
}

- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
        self.Myaction = dic[@"action"];
    }
    return self;
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

- (id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}

#pragma mark - 搜索结果
+ (void)Topic_listsMixedWithblock:(void (^)(NSMutableArray *array))block
{
    NSString *str = @"http://api.kuaikanmanhua.com/v1/topic_lists/mixed";
    [AFNetworkHandler GETwithAFNByURL:str completion:^(id result) {
        NSArray *tempArr = result[@"data"][@"topics"];
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dic in tempArr) {
            ZYLTopic_listsMixedModel *model = [[ZYLTopic_listsMixedModel alloc] initWithDic:dic];
            if ([model.type integerValue] == 1) {
                NSMutableArray *tempArr0 = model.comics;
                model.comics = [NSMutableArray array];
                for (NSDictionary *dic in tempArr0) {
                    ZYLComicModel *comicModel = [[ZYLComicModel alloc] initWithDic:dic];
                    [model.comics addObject:comicModel];
                    [comicModel release];
                }
            }
            if ([model.type integerValue] == 0) {
                NSMutableArray *tempArr1 = model.topics;
                model.topics = [NSMutableArray array];
                for (NSDictionary *dic in tempArr1) {
                    ZYLSearchResultModel *topicModel = [[ZYLSearchResultModel alloc] initWithDic:dic];
                    [model.topics addObject:topicModel];
                    [topicModel release];
                }
            }
            [arr addObject:model];
            [model release];
        }
        block(arr);
    }];
}




@end
